-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: display issue in explorer indexers #981
Conversation
@@ -40,7 +40,7 @@ const [hasMetadataRendered, setHasMetadataRendered] = useState(false); | |||
const [indexers, setIndexers] = useState([]); | |||
const [total, setTotal] = useState(0); | |||
const [currentPageIndexer, setCurrentPageIndexer] = useState([]); | |||
const [page, setPage] = useState(0); | |||
const [page, setPage] = useState(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think setPage being initialized to 1 is confusing. Instead, could you modify the handleLoadMore to do something like:
const newPage = page + 1;
// Do load more logic using newPage
setPage(newPage);
I feel the above reads a little nicer? Ideally, you would do setPage first, but I wonder if there could be lag in setting the value, so I am fine making that the last item.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, I was the one who did it in a more unconventional setting before.
It's more common to start the initial page state at 1. This is because pagination systems often use 1-based indexing, where the first page is labeled as page 1. Some systems and APIs use 0-based indexing, where the first page is labeled as page 0 but for consistency and user-friendliness, starting at 1 is generally more intuitive, as it aligns with typical expectations
Edit:
Ah yeah I did some more research. Redux and other tools define it index based. Will change this
explore seems to be missing a few indexers and the reason was due to pagination starting from 0. so on load it would grab the intial 50 and then onclick for loadmore it would still grab the 0-50 already on display.
fix: changes page to intialize to 1.
Initial Load (0-49) Indexers Loaded
First Click (page = 1): Loads indexers from 50 to 99.
Second Click (page = 2): Loads indexers from 100 to 149.